 <style type="text/css">
/* 图片展示样式 */
.images_zone{position:relative; width:120px;height:120px; overflow:hidden; float:left; margin:3px 5px 3px 0; background:#f0f0f0;border:5px solid #f0f0f0; }
.images_zone span{display:table-cell;text-align: center;vertical-align: middle;overflow: hidden;width: 120px;height: 120px;}
.images_zone span img{width:120px; vertical-align: middle;}
.images_zone a{text-align:center; position:absolute;bottom:0px;left:0px;background:rgba(255,255,255,0.5); display:block;width:100%; height:20px;line-height:20px; display:none; font-size:12px;}
/* 进度条样式 */
.up_progress{width: 300px;height: 13px;font-size: 10px;line-height: 14px;overflow: hidden;background: #e6e6e6;margin: 5px 0;display:none;}
.up_progress .progress-bar{height: 13px;background: #11ae6f;float: left;color: #fff;text-align: center;width:0%;}
.up_progress1{width: 100%;height: 16px;font-size: 10px;line-height: 14px;overflow: hidden;background: #e6e6e6;margin: 5px 0;display:none;}
.up_progress1 .progress-bar1{height: 13px;background: #11ae6f;float: left;color: #fff;text-align: center;width:0%;}
.fileinput_a{display:inline-block; width:120px; height:120px; background-image: url(assets/imgs/upload.jpg);  position:relative; overflow:hidden;}
.fileinput_a:hover{background-image: url(assets/imgs/upload.jpg); }
.fileinput_input{position:absolute; right:0; top:0; font-size:100px; opacity:0; filter:alpha(opacity=0);}
</style>

<style type="text/css">
.span_size{/*字数限制  */display: block;width: 100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;/*换行  */display:block;word-break: break-all;word-wrap: break-word;}
.h7{height:70px;padding-left: 0px;padding-right: 0px;}
.pt10{height:60px;float:left;padding-left: 2px; padding-right: 0px;padding-top: 10px;}
.pt15{align:center;height:60px;float:left;padding-left: 0px; padding-right: 0px;padding-top: 15px}

.tr-m {
	background-color: #fdfdfd;
}
hr {
border-top: 0.11px #efefef solid
}
.uploadDiv {
background-color: #fff;
	position: absolute;
	width: 100%;
	height: 63px;
	overflow: hidden;
	opacity: 0;
	filter: alpha(opacity=0);
	cursor: pointer;
}

.Line_feed{
	/*换行  */
	  display:block;
	  word-break: break-all;
	  word-wrap: break-word;
	}
.level1 span {
	border-left: 1px solid #aaa;
    padding-right: 15px;
    margin-right: 15px;
}
p {
	line-height: 1.9em
}
</style>
<div class="main_fr_mic" style="margin-bottom:10px;">
        <i class="glyphicon glyphicon-home"></i>
        <a href="admin/index">首页</a><span>></span>
        <a  class="active">审核</a><span>></span>
        <a class="active">设备借用申请</a>
</div>
<div id="mainVueApp" style="background-color: #fff;">
	<div class="main_fr_down over">
		<div class="main_fr_search over mb10">
			  <form id="search_submit" class="form-inline">
				  <div class="good_top22">
					<span class="good_top021">借用申请</span>
					<span class="good_top022">
					 	<input type="button" onclick="update(0);" class="search_an01" value="新增">
					   </span>
				  </div>
				  <div class="main_fr_search_cx">
					<!-- 标题<input name="printerReserve.name" placeholder="请输入标题名称" type="text" class="srk" style="width:200px;"/> -->
		              	申请状态<select name="status" class="srk" style="width:200px;">
		              		<option value="">请选择</option>
		              		<option value="0">待审核</option>
			              	<option value="1">审核通过</option>
			              	<option value="2">退回</option>
			              	<option value="3">使用中</option>
			              	<option value="4">归还成功</option>
			              	<option value="5">已提交归还申请</option>
			              	<!-- 状态：0待审核，1审核通过，2退回，3设备中，4设备结束，5删除 -->
		              	  </select>
		              	<input type="button" onclick="search(1);" class="search_an01 anbg" value="查询">	
				  </div>
			  </form>
		</div>
		<div class="sh_search over mb10">
			<div class="row">
				<div class="col-xs-7">
					<div class="col-xs-6">模型信息</div>
					<div class="col-xs-5">设备信息</div>
				</div>
				<div class="col-xs-5">
					<div class="col-xs-4">备注信息</div>
					<div class="col-xs-4">状态</div>
					<div class="col-xs-4">操作 </div>
				</div>
			</div>
		</div>
		<div id="reserveList" class="hide">
			<div v-for="(r, index) in reserveList" class="sh_search over mb10 level1">
				<div class="" style="font-size: 16px; color: #940a0afc; background-color:#fdfdfd ;min-height:39px; margin-bottom: 0px; padding-top: 5px;">
					<i style="color: #99f;margin-right: 8px" class="iconfont icon-hezhunshenqing"/>
					<span v-if="r.user">申请人：{{ r.user.name }}（学号：{{ r.userId }}）</span>
					<span v-if="r.user">专业：{{ r.user.major }}</span>
					<span v-if="r.user">联系电话：{{ r.user.phone }}</span>
					<p style="margin-left:30px; font-size:14px; color:#888;"><span>用途：{{ r.purpose }}</span>
					<span>创建时间：{{ r.createTime }}</span> 
					<span>申请编号：{{ r.id }}</span>
				</div>
				<!-- <div class="col-sm-4" style="height:180px;border:1px solid #D5D5D5" >
				</div> -->
				<!-- <br> -->
				<div class="col-xs-7">
					<div v-for="r2 in r.devices" class="row" style="padding-top: 5px;">
						<div class="col-sm-6 pull-left">
							<div class="pull-left" style="padding-right: 8px;">
								<i style="color: #cbc;margin-right: 8px" class="iconfont icon-icon"/>
								<!-- <a href="#" @click.prevent="threedPreview(r2.model_id)" class="editFile operation-btn fix-botm">
									<img width="70" :alt="r2.name" :src="r2.thumb"> <br>
									<em class="glyphicon glyphicon-eye-open"></em> 照片预览
								</a> -->
							</div>
							<div class="pull-left">
								<p>名称：<span class="f-name">{{ r2.name }}</span>
								<p>型号：<span class="f-chicun">{{ r2.model }}</span>
								<!-- <p>表面积：<span class="f-bmj">{{ r2.total_area }}</span> mm<sup>2</sup>
								<p>体积：<span class="f-tiji">{{ r2.volume }}</span> mm<sup>3</sup>
								<p><a :href="'threed/downloadByFileId?modelFileId=' + r2.model_id">下载</a> -->
							</div>
						</div>
						<!-- <div class="col-xs-1">{{ r2.counter }}</div> -->
						<div class="col-xs-3">
							<!-- <p>设备材料：{{ r2.material_type }}</p>
							<p>颜色：{{ r2.material_color }}</p>
							<p>填充：{{ r2.blank }}</p> -->
							<p>借用/库存：{{r2.needCount}} / {{ r2.count }}</p>
							
						</div>
						<div class="col-xs-2">
							<p v-if="r.status == 3">
								<i v-if="r2.printer_id == 0">
									 设备排队中...
								</i>
								<i v-if="r2.printer_id != 0">
									<a href="#" @click.prevent="scan(index,r2.id)"   class="btn btn-default">设备监控</a>
								</i>
							</p>
						</div>
					</div>
				</div>
				
				<div class="col-xs-5">
					<div class="col-xs-4" style="padding-top: 5px;"><span class="Line_feed">{{ r.des }}</span></div>
					<div class="col-xs-4" style="padding-top: 5px;">
							<p v-if="r.status == 0">待审核</p>
							<p v-if="r.status == 1">审核通过 </p>
							<p v-if="r.status == 2">未通过 </p>
							<p v-if="r.status == 3">使用中</p>
							<p v-if="r.status == 4" class="text-success">归还成功</p>
							<p v-if="r.status == 5">已申请归还：确认归还 </p>
							<!-- 状态：0待审核，1审核通过，2退回，3设备中，4设备结束，5删除 -->
					</div>
					<div class="col-xs-4" style="padding-top: 5px;">
							  <p v-if="r.status == 0">
								<button type="button" class="btn btn-success" @click.prevent="removeRow2(index,r.id)">
									<i class="glyphicon glyphicon-ok"></i>通过
								</button>
								<button type="button" class="btn btn-danger" @click.prevent="removeRow2(index,r.id)">
									<i class="icon-only glyphicon glyphicon-remove bigger-110"></i>拒绝
								</button>
							  </p>
							  <p v-if="r.status == 1">
							  	<button type="button" class="btn btn-success" @click.prevent="removeRow2(index,r.id)">
									<i class="glyphicon glyphicon-camera"></i>拍照借出
								</button>
								<button type="button" class="btn btn-info" @click.prevent="removeRow2(index,r.id)">
									<i class="glyphicon glyphicon-download-alt"></i>下载打印
								</button>
							  </p>
							  <p v-if="r.status == 5">
							  	<button type="button" class="btn btn-success" @click.prevent="removeRow2(index,r.id)">
									<i class="glyphicon glyphicon-camera"></i>确认归还
								</button>
							  </p>
					</div>
				</div>
				<hr/>
			</div>
		</div>
	</div>
	<div id="pages" class="text-right"></div>	
<!-- 弹出层 -->
	<div id="addFormDiv" class="hide" style="padding: 15px 29px 0;">
		<div class="sh_search mb10" style="background-color: #fff;">
			<div class="text-right">
				<!-- <button class="layui-btn layui-btn-normal">从我的模型库选择</button> -->
			</div>
			<div class="main_fr_search over mb10" style="height: 83px; background-color: #f7f7f7;">
				<div class="text-center">
					<input class="uploadDiv" id="fileupload" accept=".stl" type="file" name="file" multiple>
					<span class="h4">将STL格式文件直接到此处，或点击上传</span>
					<img src="images/upload.png" height="60px">
				</div>
				
			</div>
			<div style="clear:both;"></div><div class="up_progress1"><div class="progress-bar1"></div></div>
		        <div style="clear:both;"></div>
		</div>
		<div class="sh_search over mb10">
			<table class="table table-hover">
				<thead class="table_heaer">
					<tr class="data-hd">
						<th style="width:22%;">文件信息<em id="editAllFile" class="icon-edit"></em></th>
						<th style="width:16%;">设备信息<em id="editAllPrint" class="icon-edit"></em></th>
						<th style="width:12%;">数量</th>
						<th style="width:10%;">操作</th>
					</tr>
				</thead>
				<tbody id="projectTable">
					<tr v-for="(r, index) in list">
						<td>
							<div class="pull-left">
								<!-- <img width=70 alt="{{ r.name }}" :src="r.thumb"> -->
								<br/>
								<a href="#" @click.prevent="threedPreview(r.id)" class="editFile operation-btn fix-botm">
									<img width="70" :alt="r.name" :src="r.thumb"> <br>
									<em class="glyphicon glyphicon-eye-open"></em> 3D预览
								</a>
							</div>
							<div class="pull-left">
								<p>名称：<span class="f-name">{{ r.name }}</span></p>
								<p>尺寸：<span class="f-chicun">{{ r.x }} * {{ r.y }} * {{ r.z }}</span> cm</p>
								<p>表面积：<span class="f-bmj">{{ r.totalArea }}</span> mm<sup>2</sup></p>
								<p>体积：<span class="f-tiji">{{ r.volume }}</span> mm<sup>3</sup></p>
							</div>
						</td>
						<td class="file-info">
							<p>物料：<span id="wl_">{{ r.type }}</span> </p>
							<p>颜色：<span>{{ r.color }}</span></p>
							<p>填充：<span>{{ r.blank }}</span></p> 
							<p>重量：<span>{{ r.weight * r.counter }} 克</span></p>
							<a class="editFile operation-btn fix-botm" href="#" @click.prevent="modifyMaterial(index,r.volume)">
							<em class="glyphicon glyphicon-edit"></em> 修改</a>
						</td>
						<td>
						  <div class="ace-spinner middle touch-spinner"
								style="width: 125px;">
							</div>
						</td>
						<td>
							<button type="button" class="btn btn-danger" @click.prevent="removeRow(index)">
								<i class="icon-only glyphicon glyphicon-remove bigger-110"></i> 删除
							</button>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div>
			<label for="exampleInputEmail2" class="control-label">备注信息</label>
			<textarea rows="5" cols="80%" style="width:100%" id="des" name="des" placeholder="请输入备注信息"></textarea>
			<!-- <script id="content1" type="text/plain"></script> -->
		</div>
		<br><br><br><br>
		<div align="center">
			<button class="btn btn-success" onclick="onSubmit()">立即提交</button>
			<button type="reset" class="btn btn-default">重置</button>
		</div>
	</div>
	
	<!-- 物料修改弹出层 -->
	<div id="modifyMaterial" class="hide" style="padding: 15px 29px 0;">
		<input type="hidden" value="" id="list_index"/>
		<input type="hidden" value="" id="volume"/>
		<div class="form-group">
			<label for="inputEmail3" class="col-sm-2 control-label">物料类型</label>
			<div class="col-sm-9">
				<select id="type" name="materials_type" class="srk materials_type" style="width:200px;height:30px;">
	              		 
	            </select>
			</div>
		</div>
		<div class="form-group">
			<label for="inputEmail3" class="col-sm-2 control-label">物料颜色</label>
			<div class="col-sm-9">
				<select id="color" name="materials_color" class="srk materials_color" style="width:200px;height:30px;">
	              		 
	            </select>
			</div>
		</div>
	
		<div class="form-group">
			<label for="inputEmail3" class="col-sm-2 control-label">填充</label>
			<div class="col-sm-9">
			<select id="blank" name="blank" class="srk" style="width:200px;height:30px;">
              		<option value="空心">空心</option>
              		<option value="实心">实心</option>
            </select> 
			</div>
		</div>
		<br><br><br><br>
		<div class="form-group" align="center">
			<button class="btn btn-success" onclick="onSubmit2()">立即提交</button>
			<button type="reset" class="btn btn-default">重置</button>
		</div>
	</div>
</div>


<script src="assets/js/vue.min.js" type="text/javascript"></script>
<!-- 引入组件库 -->
<script>
var mmt;
var vm = new Vue({
	el: '#mainVueApp',
	data: {
		num1: 1,
		hasStl: false,
		list: [],
		reserveList: []
	},
	methods: {
		handleChange(value) {
	        console.log(value);
	    },
		modifyMaterial: function(index,volume) {
			$("#list_index").val(index);
			$("#volume").val(volume);
			$("#modifyMaterial").removeClass("hide");
		mmt = layer.open({
				type: 1,
				area: ['30%','35%'],
				title: '物料选择',
				content: $("#modifyMaterial")
			})
		},
		removeRow: function(index) {
			var $this = this;
			layer.confirm('确定要删除吗？', {
				title:false,
				skin:'layer-class',
				closeBtn: 0,
				btn: ['确定','取消'] //按钮
				}, function(){
					$this.list.splice(index, 1);
					layer.msg("删除成功");
				}, function(){
				});
		},
		removeRow2: function(index,id) {
			var $this = this;
			layer.confirm('确定要取消该申请吗？', {
				title:false,
				skin:'layer-class',
				closeBtn: 0,
				btn: ['确定','取消'] //按钮
				}, function(){
					$.post('printerReserve/delete', {id:id}, function(data){
						if(data.code==0){
							$this.reserveList.splice(index, 1);
							layer.msg("取消成功！");
						}else{
							layer.msg("取消失败！");
							return false;
						}
					}) 
				
				}, function(){
				});
		},
		scan: function(index,id) {
			mmt = layer.open({
				type: 2,
				area: ['880px', '550px'],
				title: '实时监控',
				content: 'monitor/getScan?id='+id
			})
		},
		threedPreview: function(fileId) {
			layer.open({
				type: 2,
				title: "3D模型预览",
				area: ['80%', '80%'],
				content: 'admin/manage/72?id=' + fileId
			})
		}
	}
})
</script>

<script>
var cc=1;
function pageChange(curr) {
	$.get("items/deviceApply/withDevice?current="+curr, $("#search_submit").serialize(), function(data) {
		$("#reserveList").removeClass("hide");
		vm.reserveList = data.content.records;
		/* userList(data.content.list); */
		layui.laypage.render({
		    elem: 'pages', //容器。值支持id名、原生dom对象，jquery对象,
		    pages: data.content.pages, //总页数
		    count: data.content.total,
		    layout: ['count', 'prev', 'page', 'next', 'skip'],
		    theme: '#4599e0',
		    curr: data.content.current,
		    groups: 3, //连续显示分页数
		    jump: function(obj, first) {
		    	if(!first){ //一定要加此判断，否则初始时会无限刷新
		    		cc=obj.curr;
		    		pageChange(obj.curr);
		    	}
		    }
		});
	});
}
pageChange(1);
function search(curr){
	if(curr != 1){
		curr=cc;
	}
	pageChange(curr);
}
var index;
var validator;
 
function update(id) {
	var tit = "申请设备";
	if(id != 0){ // 那么是编辑修改信息，需要获取模型文件列表
		$.post("printerReserve/getInfo",{id:id},function(data){
			if(data.code==0){
				for (var key in data.content){
					$("#"+key).val(data.content[key]);
					$("#column_name").val(data.content['name']);
					
				}
				$("#content").html(data.content['main_body']);
				var imgshow = '<div class="images_zone"><input type="hidden" id ="img" name="printerReserve.img_path" value="'+data.content['img_path']+'" /><span><img src="'+data.content['img_path']+'"  /></span><a href="javascript:;">删除</a></div>';
	       	     $(".files").empty();
	       	     jQuery('#image_path').append(imgshow);	//将上传之后的图片放到image_path容器中
	       	     $("#image_fileDiv").addClass("hide");
		 		     
	       	  if(data.content['img_path']==null || data.content['img_path']==""){
						$("#image_path").empty();
						$("#image_fileDiv").removeClass("hide");
			  }
			}else{
				layer.msg("获取信息失败！");
				return false;
			}
		})
		tit = "修改申请设备信息";
	}else{
		/* document.getElementById("addForm").reset(); */
		$("#id").val("");
		$("#image_path").empty();
		vm.list=[];
		$("#image_fileDiv").removeClass("hide");
	} 
 	$("#addFormDiv").removeClass("hide");
	index=layer.open({
		type : 1,
		area: ['1000px','95%'],
		title : tit,
		content : $("#addFormDiv"),
		
		cancel: function(index, layero) {
			// validator.resetForm();//// 重置表单验证提示
			    
			$("#addFormDiv").addClass("hide");
			layer.close(index);
		} 
	})
};
function newAdd(parent_id) {
	var tit = "新增下级模型信息";
		/* document.getElementById("addForm").reset(); */
		$("#id").val("");
		$("#parent_id").val(parent_id);
		$("#image_path").empty();
		$("#image_fileDiv").removeClass("hide");
 	$("#addFormDiv").removeClass("hide");
	index=layer.open({
		type : 1,
		area: ['50%','85%'],
		title : tit,
		content : $("#addFormDiv"),
		
		cancel: function(index, layero) {
			 validator.resetForm();//// 重置表单验证提示
			    
			$("#addFormDiv").addClass("hide");
			layer.close(index);
		} 
	})
};
function fujianList(id){
	layer.open({
		type : 2,
		area: ['80%', '80%'],
		offset: 0,
		shift: 1,
		scrollbar: false,
		title: '附件',
		content : 'printerReserve/index2?id='+id,
	})
	return ;
}
function clickDelete(obj) {
	// 给删除按钮注册事件
	// 获取当前记录的信息写入
	if(confirm("确定要删除该模型吗？")){
		var recordId = obj.attr("recordId");
		$.get("printerReserve/del", {"id":recordId}, function(data) {
			if (data.code == 0) {
				obj.closest("tr").remove();
				layer.msg("删除成功！");
			}else{
				layer.msg("删除失败！");
				return false;
			} 
		})
	}
}
</script>

<script type="text/javascript">
/* var um = UM.getEditor('content1', {autoHeight: false, initialFrameHeight: 250});
um.setWidth("97%");	 */
var type_val;
var color_val; 
var blank_val="空心";
var accuracy;//密度
//获取推荐物料信息
$.post('materials/getRecommend', {code:"materials_type"}, function(data){
	var dataStr = "";
	if(data.code==0){
		  type_val =data.content.mtype;
		  color_val = data.content.mcolor; 
		  accuracy  = data.content.accuracy; 
	}else{
	}
}) 
 
$(function () {
	$('#fileupload').fileupload({
		url: 'fileUpload/uploadStl',
		dataType: 'json',
		add: function (e, data) {//将要上传的文件名显示在一个元素节点上：你可以经常要将上传的文件显示到特定的元素上，这个可以通过add回调函数来实现：
	    	var select = $("#type").val();//获取选择框数据
	    	var uploadErrors = [];//创建一个包含错误类型的数组acceptFileTypes = /^image\/(gif|jpe?g|png)$/i;
	 		var acceptFileTypes = /^application\/(netfabb)$/i;//设置上传文件的类型application/netfabb
	 		var acceptFileSize = 50*1024*1024;//50M;
	 		//alert(data.originalFiles[0]['type']);
	 		
	 		if(data.originalFiles[0]['type'].length && !acceptFileTypes.test(data.originalFiles[0]['type'])) {
	 			layer.msg('文件类型不正确！');
	  		 	return false;
	  		} 
	 		if(data.originalFiles[0]['size'] > acceptFileSize) {
	  		   layer.msg('文件太大了！最大50M');
	  		   return false;
	  		}
	 		 
	 		//**************************自动上传**************************
 	 		$('.up_progress1 .progress-bar1').css('width','0px');//给进度条添加样式
		    $('.up_progress1').show();//显示进度条
		    $('.up_progress1 .progress-bar1').html('Uploading...');//显示进度条文字
		    data.submit(); 
		    //**************************自动上传**************************
		},
		done: function(e, data) {
			$('.up_progress1').hide();
			var resultJson = data.result;
			if (typeof resultJson) {
				var code = resultJson.code;
				switch (code) {
				case 0:
					// 正确处理结果，这个地方应该有stl文件的路径，在此处加载stl文件，然后调用工具方法获取结果值
					var loader = new THREE.STLLoader();
					loader.load( resultJson.content.path, function ( geometry ) {
				
						// 计算的分水岭
						var attrib = geometry.getAttribute("position");
				    	if (attrib === undefined) {
				            throw new Error("缺少位置属性")
				        }
				    	var positions = attrib.array;
				        var vertices = [];
				        for (var i = 0,
				            n = positions.length; i < n; i += 3) {
				            var x = positions[i];
				            var y = positions[i + 1];
				            var z = positions[i + 2];
				            vertices.push(new THREE.Vector3(x, y, z))
				        }
				        var faces = [];
				        for (var i = 0,
				                 n = vertices.length; i < n; i += 3) {
				            faces.push(new THREE.Face3(i, i + 1, i + 2))
				        }
				        geometry.vertices = vertices;
				        geometry.faces = faces;
				        geometry.computeFaceNormals();
				        // geometry.mergeVertices();
				        geometry.computeVertexNormals();
				        THREE.GeometryUtils.center(geometry);
				        
				        // mesh.useQuaternion = true;
				        var axis = new THREE.Vector3(100, 100, 100).normalize();
				        var angle = Math.PI / .3;
				        var q = (new THREE.Quaternion).setFromAxisAngle(axis, angle);
				        
				        xsize = geometry.boundingBox.max.x - geometry.boundingBox.min.x;
				        ysize = geometry.boundingBox.max.y - geometry.boundingBox.min.y;
				        zsize = geometry.boundingBox.max.z - geometry.boundingBox.min.z;
				        
				        console.log(xsize + ":" + ysize + ":" + zsize);
						var newStl = {
								name: resultJson.content.name,
								counter: 1,
								id: resultJson.content.id,
								x: xsize.toFixed(2),
								y: ysize.toFixed(2),
								z: zsize.toFixed(2),
								thumb: resultJson.content.thumb, // 缩略图
								volume: volAndArea[0].toFixed(2),
								totalArea: volAndArea[1].toFixed(2),
								uploadPath: resultJson.content.path,
								type:type_val,
								color:color_val,
								blank:blank_val,
								weight:(volAndArea[0]*accuracy).toFixed(2),
								accuracy:accuracy
						
								
						}
						vm.list.push(newStl);
					});
					 
					break;
				case 1:
					location.reload();
				default:
					location.reload();
					break;
				}
			}
		},
		progressall: function (e, data) {//所有文件的总体上传进度(progressall)显示
		    	console.log(data);
		        var progress = parseInt(data.loaded / data.total * 100, 10);
		        $('.up_progress1 .progress-bar1').css('width',progress + '%');
		}
	});
});

function onSubmit() {
	var des = $("#des").val();
	var filesInfo = vm.list;
	if(filesInfo==null || filesInfo==""){
		layer.msg("请上传要设备的模型！");
		return false;
	}
	//alert(filesInfo);
	$.ajax({
        type: "POST",
        traditional :false,
        url: "printerReserve/judgment",
        data: {"remark": des, "filesInfo": JSON.stringify(filesInfo)}, 
        cache: false,
        success: function(res){
			if (res.code == 0) {//没有超出系统设置的警戒值
				$.ajax({
			        type: "POST",
			        traditional :false,
			        url: "printerReserve/add",
			        data: {"remark": des, "filesInfo": JSON.stringify(filesInfo)}, 
			        cache: false,
			        success: function(res){
						if (res.code == 0) {
							layer.msg("添加成功");
							location.reload();
						}
			        }
			    });
			}else if(res.code == 3){//本次申请已超出系统设置的警戒值
				 if(confirm("本次申请已超出系统设置的用户累计可设备的最大重量，有审核不通过的可能，是否确定继续提交申请吗？")){
					 $.ajax({
					        type: "POST",
					        traditional :false,
					        url: "printerReserve/add",
					        data: {"remark": des, "filesInfo": JSON.stringify(filesInfo)}, 
					        cache: false,
					        success: function(res){
								//alert(JSON.stringify(res));
								if (res.code == 0) {
									layer.msg("添加成功");
									location.reload();
								}
					        }
					  });
				 }
			}
        }
    });
	return false;
}
//获取物料分类信息
$.post('materials/getTypeList', {code:"materials_type"}, function(data){
	var dataStr = "";
	if(data.code==0){
		dataStr+="<option value=''>选择分类</option>";
		$.each(data.content, function(i, v) {
			dataStr+="<option value='"+v.type+"'>"+v.content+"</option>";
		})
		$(".materials_type").html(dataStr);
	}else{
		layer.msg("获取分类信息为空！");
		return false;
	}
}) 
$("#type").change(function(){
	var type = $("#type").val();
	//获取物料颜色信息
	$.post('materials/getColorList', {type:type}, function(data){
		var dataStr = "";
		if(data.code==0){
			dataStr+="";
			$.each(data.content, function(i, v) {
				dataStr+="<option value='"+v.accuracy+"'>"+v.content+"</option>";
			})
			$(".materials_color").html(dataStr);
		}else{
			layer.msg("获取颜色信息为空！");
			$(".materials_color").html("");
			return false;
		}
	}) 
   });
function onSubmit2(){
	var index = $("#list_index").val();
	var type = $("#type").find("option:selected").text();
	var color = $("#color").find("option:selected").text();
	var blank = $("#blank").val();
	if($("#type").val()==null || $("#type").val()==""){
		layer.msg("请选择物料类型！");
		return false;
	}
	vm.list[index].type = type;
	vm.list[index].color = color;
	vm.list[index].blank = blank;
	//type,color,blank
	//计算重量
		var accuracy1 = $("#color").val();//密度
		var volume = $("#volume").val();//体积
		var counter = vm.list[index].counter;//数量
		var weight = (accuracy1*volume).toFixed(2)//重量
		vm.list[index].accuracy = accuracy1;
		vm.list[index].weight = weight;
		
		
	layer.close(mmt);
}
</script>